<?php

/*
 * To change this template,: choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of UsersQuery
 *
 * @author juwking
 */
class ClientsQuery extends TableControl {

    protected $user = 'root', $password, $dbase = 'wincon_mailing_db';

    function __construct() {
        parent::__construct();
    }

    function Select($param=null, $limit=null) {
        if (!is_int($param))
            $queryString = "Select * from client where name like '%" . $param['name'] . "%' and surname like '%" . $param['surname'] . "%' and email like '%" . $param['email'] . "%'";
        else {
            $queryString = "Select * from client LIMIT " . $param . ',' . $limit;
        }
        $result = $this->pdo->query($queryString);
        $result->setFetchMode(PDO::FETCH_ASSOC);
        return $result->fetchAll();
    }

    function Insert($param) {
        $this->initPDO();
        $queryString = "INSERT INTO client (client_categories_id,name,surname,gender,age,email,status,allowed_binary_code) VALUES (:client_categories_id,:name,:surname,:gender,:age,:email,:status,:allowed_binary_code)";
        $stmt = $this->pdo->prepare($queryString);
        $stmt->bindParam(':client_categories_id', $param['client_categories_id']);
        $stmt->bindParam(':name', $param['name']);
        $stmt->bindParam(':surname', $param['surname']);
        $stmt->bindParam(':gender', $param['gender']);
        $stmt->bindParam(':age', $param['age']);
        $stmt->bindParam(':email', $param['email']);
        $stmt->bindParam(':status', $param['status']);
        $stmt->bindParam(':allowed_binary_code', $param['allowed_binary_code']);
        $stmt->execute();
    }

    function Update($param) {

    }

    function Delete($param) {

    }

    function getEmptyRecord() {

    }

    public function getTableName() {
        return 'clients';
    }

    public function getColumns() {
        return array('client_id', 'client_categories_id', 'client_organization_id', 'name', 'surname', 'gender', 'age', 'email', 'status', 'allowed_binary_code');
    }

}

?>
